﻿

using Maticsoft.BLL;
using Maticsoft.DBUtility;
using System;
using System.Data;
using System.Text;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Wuqi.Webdiyer;

public partial class WebPage_Index_YouqingLianjie : SystemBBasePage
{

    private string sql = "";
    private int text = Convert.ToInt32(PageIndex.pageIndex);

    Friendlink friendLink = new Friendlink();

    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        this.getYouqingLianjie();
    }

    private void getYouqingLianjie()
    {
        StringBuilder builder = new StringBuilder();
        builder.Append("<tr >");
        builder.Append("<th width='40' nowrap>ID</th>");
        builder.Append("<th width='120' nowrap>网站名称</th>");
        builder.Append("<th width='200' nowrap>网站网址</th>");
        builder.Append("<th width='80%' nowrap>LOGO</th>");
        builder.Append("<th width='60' nowrap>排序</th>");
        builder.Append("<th width='120' colspan='2' nowrap>操作</th>");
        builder.Append("</tr>");
        StringBuilder builder2 = new StringBuilder();
        int count = 0;
        DataTable table = DbHelperSQL.GetDataTableByPager(this.text, this.AspNetPager1.CurrentPageIndex, "Sort_order desc,Id desc", this.sql, "friendLink", out count);
        this.AspNetPager1.PageSize = this.text;
        this.AspNetPager1.RecordCount = count;
        if (table.Rows.Count > 0)
        {
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if ((i % 2) != 0)
                {
                    builder2.Append("<tr>");
                }
                else
                {
                    builder2.Append("<tr class='alt'>");
                }
                builder2.Append("<td width='40' nowrap>" + table.Rows[i]["Id"] + "</td>");
                builder2.Append("<td width='120' nowrap>" + table.Rows[i]["Title"] + "</td>");
                builder2.Append("<td width='200' nowrap>" + table.Rows[i]["url"] + "</td>");
                builder2.Append("<td width='80%' nowrap>" + table.Rows[i]["Logo"] + "</td>");
                builder2.Append("<td width='60' nowrap>" + table.Rows[i]["Sort_order"] + "</td>");
                builder2.Append(string.Concat(new object[] { "<td width='120' colspan='2' nowrap> <a class='ajaxlink' href='/ajax/misc.aspx?action=link&id=", table.Rows[i]["Id"], "'>编缉</a> | <a class=\"remove-record\" href='Index-YouqingLianjie.aspx?del=", table.Rows[i]["Id"], "&pageIndex=", this.AspNetPager1.CurrentPageIndex, "&where=", DESEncrypt.Encrypt(this.sql, "type"), "'>删除</a></td>" }));
                builder2.Append("</tr>");
            }
        }
        this.Literal1.Text = builder.ToString();
        this.Literal2.Text = builder2.ToString();
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        this.HeaderControl1.Select = "index";
        if (base.Request.QueryString["del"] != null)
        {
            this.friendLink.Delete(int.Parse(base.Request.QueryString["del"].ToString()));
            base.SetSuccess("删除成功");
            if ((base.Request.QueryString["pageIndex"] != null) && (base.Request.QueryString["pageIndex"].ToString() != ""))
            {
                this.AspNetPager1.CurrentPageIndex = Convert.ToInt32(base.Request.QueryString["pageIndex"].ToString());
            }
            if ((base.Request.QueryString["where"] != null) && (base.Request.QueryString["where"].ToString() != ""))
            {
                this.sql = DESEncrypt.Decrypt(base.Request.QueryString["where"].ToString(), "type");
            }
        }
        this.getYouqingLianjie();
    }
}


